#ifndef _INV_MPU_DMP_MOTION_DRIVER_H_
#define _INV_MPU_DMP_MOTION_DRIVER_H_

#include <stdint.h>

// DMP features
#define DMP_FEATURE_TAP             (0x001)
#define DMP_FEATURE_ANDROID_ORIENT  (0x002)
#define DMP_FEATURE_LP_QUAT         (0x004)
#define DMP_FEATURE_PEDOMETER       (0x008)
#define DMP_FEATURE_6X_LP_QUAT      (0x010)
#define DMP_FEATURE_GYRO_CAL        (0x020)
#define DMP_FEATURE_SEND_RAW_ACCEL  (0x040)
#define DMP_FEATURE_SEND_RAW_GYRO   (0x080)
#define DMP_FEATURE_SEND_CAL_GYRO   (0x100)

// DMP output rate
#define DMP_SAMPLE_RATE             (200)

// Tap detection
#define TAP_X                       (0x01)
#define TAP_Y                       (0x02)
#define TAP_Z                       (0x04)
#define TAP_XYZ                     (0x07)

#define TAP_X_UP                    (0x01)
#define TAP_X_DOWN                  (0x02)
#define TAP_Y_UP                    (0x03)
#define TAP_Y_DOWN                  (0x04)
#define TAP_Z_UP                    (0x05)
#define TAP_Z_DOWN                  (0x06)

// Android orientation
#define ANDROID_ORIENT_PORTRAIT             (0x00)
#define ANDROID_ORIENT_LANDSCAPE            (0x01)
#define ANDROID_ORIENT_REVERSE_PORTRAIT     (0x02)
#define ANDROID_ORIENT_REVERSE_LANDSCAPE    (0x03)

// Function prototypes
int dmp_load_motion_driver_firmware(void);
int dmp_set_fifo_rate(unsigned short rate);
int dmp_get_fifo_rate(unsigned short *rate);
int dmp_enable_feature(unsigned short mask);
int dmp_get_enabled_features(unsigned short *mask);
int dmp_set_interrupt_mode(unsigned char mode);
int dmp_set_orientation(unsigned short orient);
int dmp_set_gyro_bias(long *bias);
int dmp_set_accel_bias(long *bias);
int dmp_read_fifo(short *gyro, short *accel, long *quat, unsigned long *timestamp, short *sensors, unsigned char *more);
int dmp_set_tap_thresh(unsigned char axis, unsigned short thresh);
int dmp_set_tap_axes(unsigned char axis);
int dmp_set_tap_count(unsigned char min_taps);
int dmp_set_tap_time(unsigned short time);
int dmp_set_tap_time_multi(unsigned short time);
int dmp_set_shake_reject_thresh(long sf, unsigned short thresh);
int dmp_set_shake_reject_time(unsigned short time);
int dmp_set_shake_reject_timeout(unsigned short time);
int dmp_get_tap_count(unsigned char *count);
int dmp_get_tap_dir(unsigned char *dir);
int dmp_get_orient(unsigned char *orient);
int dmp_get_gyro_bias(long *bias);
int dmp_get_accel_bias(long *bias);

// Quaternion utilities
void dmp_quaternion_to_euler(const long *quat, float *euler);
void dmp_quaternion_to_roll_pitch_yaw(const long *quat, float *rpy);

#endif  /* _INV_MPU_DMP_MOTION_DRIVER_H_ */
